<!DOCTYPE html>
<html>

<head>
  <title>Quarkus - Validation with Hibernate Validator</title>
  <script id="adobe_dtm" src="https://www.redhat.com/dtm.js" type="text/javascript"></script>
  <script src="/assets/javascript/highlight.pack.js" type="text/javascript"></script>
  <META HTTP-EQUIV='Content-Security-Policy' CONTENT="default-src 'none'; script-src 'self' 'unsafe-eval' 'sha256-ANpuoVzuSex6VhqpYgsG25OHWVA1I+F6aGU04LoI+5s=' 'sha256-ipy9P/3rZZW06mTLAR0EnXvxSNcnfSDPLDuh3kzbB1w=' js.bizographics.com https://www.redhat.com assets.adobedtm.com jsonip.com https://ajax.googleapis.com https://www.googletagmanager.com https://www.google-analytics.com https://use.fontawesome.com; style-src 'self' https://fonts.googleapis.com https://use.fontawesome.com; img-src 'self' *; media-src 'self' ; frame-src https://www.googletagmanager.com https://www.youtube.com; frame-ancestors 'none'; base-uri 'none'; object-src 'none'; form-action 'none'; font-src 'self' https://use.fontawesome.com https://fonts.gstatic.com;">
  <META HTTP-EQUIV='X-Frame-Options' CONTENT="DENY">
  <META HTTP-EQUIV='X-XSS-Protection' CONTENT="1; mode=block">
  <META HTTP-EQUIV='X-Content-Type-Options' CONTENT="nosniff">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="description" content="Quarkus: Supersonic Subatomic Java">
  <meta name="twitter:card" content="summary_large_image">
  <meta name="twitter:site" content="@QuarkusIO"> 
  <meta name="twitter:creator" content="@QuarkusIO">
  <meta property="og:url" content="https://quarkus.io/guides/validation" />
  <meta property="og:title" content="Quarkus - Validation with Hibernate Validator" />
  <meta property="og:description" content="Quarkus: Supersonic Subatomic Java" />
  <meta property="og:image" content="/assets/images/quarkus_card.png" />
  <link rel="canonical" href="https://quarkus.io/guides/validation">
  <link rel="shortcut icon" type="image/png" href="/favicon.ico" >
  <link rel="stylesheet" href="https://quarkus.io/guides/stylesheet/config.css" />
  <link rel="stylesheet" href="/assets/css/main.css" />
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">
  <link rel="alternate" type="application/rss+xml"  href="https://quarkus.io/feed.xml" title="Quarkus">
  <script src="https://quarkus.io/assets/javascript/goan.js" type="text/javascript"></script>
  <script src="https://quarkus.io/assets/javascript/hl.js" type="text/javascript"></script>
</head>

<body class="guides">
  <!-- Google Tag Manager (noscript) -->
  <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-NJWS5L"
  height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
  <!-- End Google Tag Manager (noscript) -->

  <div class="nav-wrapper">
  <div class="grid-wrapper">
    <div class="width-12-12">
      <input type="checkbox" id="checkbox" />
      <nav id="main-nav" class="main-nav">
  <div class="container">
    <div class="logo-wrapper">
      
        <a href="/"><img src="/assets/images/quarkus_logo_horizontal_rgb_600px_reverse.png" class="project-logo" title="Quarkus"></a>
      
    </div>
    <label class="nav-toggle" for="checkbox">
      <i class="fa fa-bars"></i>
    </label>
    <div id="menu" class="menu">
      <span>
        <a href="/get-started/" class="">Get Started</a>
      </span>
      <span>
        <a href="/guides/" class="active">Guides</a>
      </span>
      <span>
        <a href="/community/" class="">Community</a>
      </span>
      <span>
        <a href="/support/" class="">Support</a>
      </span>
      <span>
        <a href="/blog/" class="">Blog</a>
      </span>
      <span>
        <a href="https://code.quarkus.io" class="button-cta secondary white">Start Coding</a>
      </span>
    </div>
  </div>
      </nav>
    </div>
  </div>
</div>

  <div class="content">
    <div class="guide">
  <div class="width-12-12">
    <h1 class="text-caps">Quarkus - Validation with Hibernate Validator</h1>
    <div class="hide-mobile toc"><ul class="sectlevel1">
<li><a href="#prerequisites">Prerequisites</a></li>
<li><a href="#architecture">Architecture</a></li>
<li><a href="#solution">Solution</a></li>
<li><a href="#creating-the-maven-project">Creating the Maven project</a></li>
<li><a href="#accessing-the-validator">Accessing the Validator</a></li>
<li><a href="#constraints">Constraints</a></li>
<li><a href="#json-mapping-and-validation">JSON mapping and validation</a></li>
<li><a href="#rest-end-point-validation">REST end point validation</a></li>
<li><a href="#service-method-validation">Service method validation</a></li>
<li><a href="#a-frontend">A frontend</a></li>
<li><a href="#run-the-application">Run the application</a></li>
<li><a href="#going-further">Going further</a>
<ul class="sectlevel2">
<li><a href="#hibernate-validator-extension-and-cdi">Hibernate Validator extension and CDI</a></li>
<li><a href="#validation-and-localization">Validation and localization</a></li>
</ul>
</li>
<li><a href="#configuration-reference">Hibernate Validator Configuration Reference</a></li>
</ul></div>
    <div>
      <div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>This guide covers how to use Hibernate Validator/Bean Validation for:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>validating the input/output of your REST services;</p>
</li>
<li>
<p>validating the parameters and return values of the methods of your business services.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="prerequisites"><a class="anchor" href="#prerequisites"></a>Prerequisites</h2>
<div class="sectionbody">
<div class="paragraph">
<p>To complete this guide, you need:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>less than 15 minutes</p>
</li>
<li>
<p>an IDE</p>
</li>
<li>
<p>JDK 1.8+ installed with <code>JAVA_HOME</code> configured appropriately</p>
</li>
<li>
<p>Apache Maven 3.6.2+</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="architecture"><a class="anchor" href="#architecture"></a>Architecture</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The application built in this guide is quite simple. The user fills a form on a web page.
The web page sends the form content to the <code>BookResource</code> as JSON (using Ajax). The <code>BookResource</code> validates the user input and returns the
<em>result</em> as JSON.</p>
</div>
<div class="paragraph">
<p><span class="image"><img src="/guides/images/validation-guide-architecture.png" alt="Architecture"></span></p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="solution"><a class="anchor" href="#solution"></a>Solution</h2>
<div class="sectionbody">
<div class="paragraph">
<p>We recommend that you follow the instructions in the next sections and create the application step by step.
However, you can go right to the completed example.</p>
</div>
<div class="paragraph">
<p>Clone the Git repository: <code>git clone <a href="https://github.com/quarkusio/quarkus-quickstarts.git" class="bare">https://github.com/quarkusio/quarkus-quickstarts.git</a></code>, or download an <a href="https://github.com/quarkusio/quarkus-quickstarts/archive/master.zip">archive</a>.</p>
</div>
<div class="paragraph">
<p>The solution is located in the <code>validation-quickstart</code> <a href="https://github.com/quarkusio/quarkus-quickstarts/tree/master/validation-quickstart">directory</a>.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="creating-the-maven-project"><a class="anchor" href="#creating-the-maven-project"></a>Creating the Maven project</h2>
<div class="sectionbody">
<div class="paragraph">
<p>First, we need a new project. Create a new project with the following command:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-none hljs">mvn io.quarkus:quarkus-maven-plugin:1.7.0.Final:create \
    -DprojectGroupId=org.acme \
    -DprojectArtifactId=validation-quickstart \
    -DclassName="org.acme.validation.BookResource" \
    -Dpath="/books" \
    -Dextensions="resteasy-jsonb, hibernate-validator"
cd validation-quickstart</code></pre>
</div>
</div>
<div class="paragraph">
<p>This command generates a Maven structure importing the RESTEasy/JAX-RS, JSON-B and Hibernate Validator/Bean Validation extensions.</p>
</div>
<div class="paragraph">
<p>If you already have your Quarkus project configured, you can add the <code>hibernate-validator</code> extension
to your project by running the following command in your project base directory:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="bash" class="language-bash hljs">./mvnw quarkus:add-extension -Dextensions="hibernate-validator"</code></pre>
</div>
</div>
<div class="paragraph">
<p>This will add the following to your <code>pom.xml</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="xml" class="language-xml hljs">&lt;dependency&gt;
    &lt;groupId&gt;io.quarkus&lt;/groupId&gt;
    &lt;artifactId&gt;quarkus-hibernate-validator&lt;/artifactId&gt;
&lt;/dependency&gt;</code></pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="accessing-the-validator"><a class="anchor" href="#accessing-the-validator"></a>Accessing the Validator</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Edit the <code>org.acme.validation.BookResource</code> class, and inject the <code>Validator</code> object as follows:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="java" class="language-java hljs">@Inject
Validator validator;</code></pre>
</div>
</div>
<div class="paragraph">
<p>The <code>Validator</code> allows checking constraints on a specific object.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="constraints"><a class="anchor" href="#constraints"></a>Constraints</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In this application, we are going to test an elementary object, but we support complicated constraints and can validate graphs of objects.
Create the <code>org.acme.validation.Book</code> class with the following content:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="java" class="language-java hljs">package org.acme.validation;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Min;

public class Book {

    @NotBlank(message="Title may not be blank")
    public String title;

    @NotBlank(message="Author may not be blank")
    public String author;

    @Min(message="Author has been very lazy", value=1)
    public double pages;
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Constraints are added on fields, and when an object is validated, the values are checked.
The getter and setter methods are also used for JSON mapping.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="json-mapping-and-validation"><a class="anchor" href="#json-mapping-and-validation"></a>JSON mapping and validation</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Back to the <code>BookResource</code> class.
Add the following method:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="java" class="language-java hljs">@Path("/manual-validation")
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Result tryMeManualValidation(Book book) {
    Set&lt;ConstraintViolation&lt;Book&gt;&gt; violations = validator.validate(book);
    if (violations.isEmpty()) {
        return new Result("Book is valid! It was validated by manual validation.");
    } else {
        return new Result(violations);
    }
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Yes it does not compile, <code>Result</code> is missing, but we will add it very soon.</p>
</div>
<div class="paragraph">
<p>The method parameter (<code>book</code>) is created from the JSON payload automatically.</p>
</div>
<div class="paragraph">
<p>The method uses the <code>Validator</code> to check the payload.
It returns a set of violations.
If this set is empty, it means the object is valid.
In case of failures, the messages are concatenated and sent back to the browser.</p>
</div>
<div class="paragraph">
<p>Let&#8217;s now create the <code>Result</code> class as an inner class:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="java" class="language-java hljs">public static class Result {

    Result(String message) {
        this.success = true;
        this.message = message;
    }

    Result(Set&lt;? extends ConstraintViolation&lt;?&gt;&gt; violations) {
        this.success = false;
        this.message = violations.stream()
             .map(cv -&gt; cv.getMessage())
             .collect(Collectors.joining(", "));
    }

    private String message;
    private boolean success;

    public String getMessage() {
        return message;
    }

    public boolean isSuccess() {
        return success;
    }

}</code></pre>
</div>
</div>
<div class="paragraph">
<p>The class is very simple and only contains 2 fields and the associated getters and setters.
Because we indicate that we produce JSON, the mapping to JSON is made automatically.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="rest-end-point-validation"><a class="anchor" href="#rest-end-point-validation"></a>REST end point validation</h2>
<div class="sectionbody">
<div class="paragraph">
<p>While using the <code>Validator</code> manually might be useful for some advanced usage,
if you simply want to validate the parameters or the return value or your REST end point,
you can annotate it directly, either with constraints (<code>@NotNull</code>, <code>@Digits</code>&#8230;&#8203;)
or with <code>@Valid</code> (which will cascade the validation to the bean).</p>
</div>
<div class="paragraph">
<p>Let&#8217;s create an end point validating the <code>Book</code> provided in the request:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="java" class="language-java hljs">@Path("/end-point-method-validation")
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Result tryMeEndPointMethodValidation(@Valid Book book) {
    return new Result("Book is valid! It was validated by end point method validation.");
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>As you can see, we don&#8217;t have to manually validate the provided <code>Book</code> anymore as it is automatically validated.</p>
</div>
<div class="paragraph">
<p>If a validation error is triggered, a violation report is generated and serialized as JSON as our end point produces a JSON output.
It can be extracted and manipulated to display a proper error message.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="service-method-validation"><a class="anchor" href="#service-method-validation"></a>Service method validation</h2>
<div class="sectionbody">
<div class="paragraph">
<p>It might not always be handy to have the validation rules declared at the end point level as it could duplicate some business validation.</p>
</div>
<div class="paragraph">
<p>The best option is then to annotate a method of your business service with your constraints (or in our particular case with <code>@Valid</code>):</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="java" class="language-java hljs">package org.acme.validation;

import javax.enterprise.context.ApplicationScoped;
import javax.validation.Valid;

@ApplicationScoped
public class BookService {

    public void validateBook(@Valid Book book) {
        // your business logic here
    }
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Calling the service in your rest end point triggers the <code>Book</code> validation automatically:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="java" class="language-java hljs">@Inject BookService bookService;

@Path("/service-method-validation")
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Result tryMeServiceMethodValidation(Book book) {
    try {
        bookService.validateBook(book);
        return new Result("Book is valid! It was validated by service method validation.");
    } catch (ConstraintViolationException e) {
        return new Result(e.getConstraintViolations());
    }
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Note that, if you want to push the validation errors to the frontend, you have to catch the exception and push the information yourselves
as they will not be automatically pushed to the JSON output.</p>
</div>
<div class="paragraph">
<p>Keep in mind that you usually don&#8217;t want to expose to the public the internals of your services
- and especially not the validated value contained in the violation object.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="a-frontend"><a class="anchor" href="#a-frontend"></a>A frontend</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Now let&#8217;s add the simple web page to interact with our <code>BookResource</code>.
Quarkus automatically serves static resources contained in the <code>META-INF/resources</code> directory.
In the <code>src/main/resources/META-INF/resources</code> directory, replace the <code>index.html</code> file with the content from this <a href="https://github.com/quarkusio/quarkus-quickstarts/blob/master/validation-quickstart/src/main/resources/META-INF/resources/index.html">index.html</a> file in it.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="run-the-application"><a class="anchor" href="#run-the-application"></a>Run the application</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Now, let&#8217;s see our application in action. Run it with:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="bash" class="language-bash hljs">./mvnw compile quarkus:dev</code></pre>
</div>
</div>
<div class="paragraph">
<p>Then, open your browser to <a href="http://localhost:8080/" class="bare">http://localhost:8080/</a>:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Enter the book details (valid or invalid)</p>
</li>
<li>
<p>Click on the <em>Try me&#8230;&#8203;</em> buttons to check if your data is valid using one of the methods we presented above.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p><span class="image"><img src="/guides/images/validation-guide-screenshot.png" alt="Application"></span></p>
</div>
<div class="paragraph">
<p>As usual, the application can be packaged using <code>./mvnw clean package</code> and executed using the <code>-runner.jar</code> file.
You can also build the native executable using <code>./mvnw package -Pnative</code>.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="going-further"><a class="anchor" href="#going-further"></a>Going further</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="hibernate-validator-extension-and-cdi"><a class="anchor" href="#hibernate-validator-extension-and-cdi"></a>Hibernate Validator extension and CDI</h3>
<div class="paragraph">
<p>The Hibernate Validator extension is tightly integrated with CDI.</p>
</div>
<div class="sect3">
<h4 id="configuring-the-validatorfactory"><a class="anchor" href="#configuring-the-validatorfactory"></a>Configuring the ValidatorFactory</h4>
<div class="paragraph">
<p>Sometimes, you might need to configure the behavior of the <code>ValidatorFactory</code>, for instance to use a specific <code>ParameterNameProvider</code>.</p>
</div>
<div class="paragraph">
<p>While the <code>ValidatorFactory</code> is instantiated by Quarkus itself,
you can very easily tweak it by declaring replacement beans that will be injected in the configuration.</p>
</div>
<div class="paragraph">
<p>If you create a bean of the following types in your application, it will automatically be injected into the <code>ValidatorFactory</code> configuration:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>javax.validation.ClockProvider</code></p>
</li>
<li>
<p><code>javax.validation.ConstraintValidator</code></p>
</li>
<li>
<p><code>javax.validation.ConstraintValidatorFactory</code></p>
</li>
<li>
<p><code>javax.validation.MessageInterpolator</code></p>
</li>
<li>
<p><code>javax.validation.ParameterNameProvider</code></p>
</li>
<li>
<p><code>javax.validation.TraversableResolver</code></p>
</li>
<li>
<p><code>org.hibernate.validator.spi.properties.GetterPropertySelectionStrategy</code></p>
</li>
<li>
<p><code>org.hibernate.validator.spi.scripting.ScriptEvaluatorFactory</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>You don&#8217;t have to wire anything.</p>
</div>
<div class="admonitionblock warning">
<table>
<tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
<div class="paragraph">
<p>Obviously, for each listed type, you can declare only one bean.</p>
</div>
<div class="paragraph">
<p>These beans should be declared as <code>@ApplicationScoped</code>.</p>
</div>
</td>
</tr>
</table>
</div>
</div>
<div class="sect3">
<h4 id="constraint-validators-as-beans"><a class="anchor" href="#constraint-validators-as-beans"></a>Constraint validators as beans</h4>
<div class="paragraph">
<p>You can declare your constraint validators as CDI beans:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="java" class="language-java hljs">@ApplicationScoped
public class MyConstraintValidator implements ConstraintValidator&lt;MyConstraint, String&gt; {

    @Inject
    MyService service;

    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        if (value == null) {
            return true;
        }

        return service.validate(value);
    }
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>When initializing a constraint validator of a given type,
Quarkus will check if a bean of this type is available and, if so, it will use it instead of instantiating one.</p>
</div>
<div class="paragraph">
<p>Thus, as demonstrated in our example, you can fully use injection in your constraint validator beans.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>Except in very specific situations, it is recommended to make the said beans <code>@ApplicationScoped</code>.</p>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="sect2">
<h3 id="validation-and-localization"><a class="anchor" href="#validation-and-localization"></a>Validation and localization</h3>
<div class="paragraph">
<p>By default, constraint violation messages will be returned in the build system locale.</p>
</div>
<div class="paragraph">
<p>You can configure this behavior by adding the following configuration in your <code>application.properties</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="properties" class="language-properties hljs"># The default locale to use
quarkus.default-locale=fr-FR</code></pre>
</div>
</div>
<div class="paragraph">
<p>If you are using RESTEasy, in the context of a JAX-RS endpoint, Hibernate Validator will automatically resolve the optimal locale to use from the <code>Accept-Language</code> HTTP header,
provided the supported locales have been properly specified in the <code>application.properties</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="properties" class="language-properties hljs"># The list of all the supported locales
quarkus.locales=en-US,es-ES,fr-FR</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="configuration-reference"><a class="anchor" href="#configuration-reference"></a>Hibernate Validator Configuration Reference</h2>
<div class="sectionbody">
<div class="paragraph configuration-legend">
<p><span class="icon"><i class="fa fa-lock" title="Fixed at build time"></i></span> Configuration property fixed at build time - All other configuration properties are overridable at runtime</p>
</div>
<table class="tableblock frame-all grid-all stretch configuration-reference searchable">
<colgroup>
<col style="width: 80%;">
<col style="width: 10%;">
<col style="width: 10%;">
</colgroup>
<tbody>
<tr>
<th class="tableblock halign-left valign-top"><p class="tableblock"><a id="quarkus-hibernate-validator_configuration"></a><a href="#quarkus-hibernate-validator_configuration">Configuration property</a></p></th>
<th class="tableblock halign-left valign-middle"><p class="tableblock">Type</p></th>
<th class="tableblock halign-left valign-middle"><p class="tableblock">Default</p></th>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><span class="icon"><i class="fa fa-lock" title="Fixed at build time"></i></span> <a id="quarkus-hibernate-validator_quarkus.hibernate-validator.fail-fast"></a><code><a href="#quarkus-hibernate-validator_quarkus.hibernate-validator.fail-fast">quarkus.hibernate-validator.fail-fast</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>Enable the fail fast mode. When fail fast is enabled the validation will stop on the first constraint violation detected.</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><code>false</code></p></td>
</tr>
<tr>
<th class="tableblock halign-left valign-top"><p class="tableblock"><a id="quarkus-hibernate-validator_quarkus.hibernate-validator.method-validation"></a><a href="#quarkus-hibernate-validator_quarkus.hibernate-validator.method-validation">Method validation</a></p></th>
<th class="tableblock halign-left valign-middle"><p class="tableblock">Type</p></th>
<th class="tableblock halign-left valign-middle"><p class="tableblock">Default</p></th>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><span class="icon"><i class="fa fa-lock" title="Fixed at build time"></i></span> <a id="quarkus-hibernate-validator_quarkus.hibernate-validator.method-validation.allow-overriding-parameter-constraints"></a><code><a href="#quarkus-hibernate-validator_quarkus.hibernate-validator.method-validation.allow-overriding-parameter-constraints">quarkus.hibernate-validator.method-validation.allow-overriding-parameter-constraints</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>Define whether overriding methods that override constraints should throw a <code>ConstraintDefinitionException</code>. The default value is <code>false</code>, i.e. do not allow.
 See Section 4.5.5 of the JSR 380 specification, specifically "In sub types (be it sub classes/interfaces or interface implementations), no parameter constraints may be declared on overridden or implemented methods, nor may parameters be marked for cascaded validation. This would pose a strengthening of preconditions to be fulfilled by the caller."</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><code>false</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><span class="icon"><i class="fa fa-lock" title="Fixed at build time"></i></span> <a id="quarkus-hibernate-validator_quarkus.hibernate-validator.method-validation.allow-parameter-constraints-on-parallel-methods"></a><code><a href="#quarkus-hibernate-validator_quarkus.hibernate-validator.method-validation.allow-parameter-constraints-on-parallel-methods">quarkus.hibernate-validator.method-validation.allow-parameter-constraints-on-parallel-methods</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>Define whether parallel methods that define constraints should throw a <code>ConstraintDefinitionException</code>. The default value is <code>false</code>, i.e. do not allow.
 See Section 4.5.5 of the JSR 380 specification, specifically "If a sub type overrides/implements a method originally defined in several parallel types of the hierarchy (e.g. two interfaces not extending each other, or a class and an interface not implemented by said class), no parameter constraints may be declared for that method at all nor parameters be marked for cascaded validation. This again is to avoid an unexpected strengthening of preconditions to be fulfilled by the caller."</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><code>false</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><span class="icon"><i class="fa fa-lock" title="Fixed at build time"></i></span> <a id="quarkus-hibernate-validator_quarkus.hibernate-validator.method-validation.allow-multiple-cascaded-validation-on-return-values"></a><code><a href="#quarkus-hibernate-validator_quarkus.hibernate-validator.method-validation.allow-multiple-cascaded-validation-on-return-values">quarkus.hibernate-validator.method-validation.allow-multiple-cascaded-validation-on-return-values</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>Define whether more than one constraint on a return value may be marked for cascading validation are allowed. The default value is <code>false</code>, i.e. do not allow.
 See Section 4.5.5 of the JSR 380 specification, specifically "One must not mark a method return value for cascaded validation more than once in a line of a class hierarchy. In other words, overriding methods on sub types (be it sub classes/interfaces or interface implementations) cannot mark the return value for cascaded validation if the return value has already been marked on the overridden method of the super type or interface."</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><code>false</code></p></td>
</tr>
</tbody>
</table>
</div>
</div>
    </div>
  </div>
</div>

  </div>

  <div class="content project-footer">
  <div class="footer-section">
    <div class="logo-wrapper">
      <a href="/"><img src="/assets/images/quarkus_logo_horizontal_rgb_reverse.svg" class="project-logo" title="Quarkus"></a>
    </div>
  </div>
  <div class="grid-wrapper">
    <p class="grid__item width-3-12">Quarkus is open. All dependencies of this project are available under the <a href='https://www.apache.org/licenses/LICENSE-2.0' target='_blank'>Apache Software License 2.0</a> or compatible license.<br /><br />This website was built with <a href='https://jekyllrb.com/' target='_blank'>Jekyll</a>, is hosted on <a href='https://pages.github.com/' target='_blank'>Github Pages</a> and is completely open source. If you want to make it better, <a href='https://github.com/quarkusio/quarkusio.github.io' target='_blank'>fork the website</a> and show us what you’ve got.</p>

    
      <div class="width-1-12 project-links">
        <span>Navigation</span>
        <ul class="footer-links width-1-12">
          
            <li><a href="/">Home</a></li>
          
            <li><a href="/guides">Guides</a></li>
          
            <li><a href="/community/#contributing">Contribute</a></li>
          
            <li><a href="/faq">FAQ</a></li>
          
            <li><a href="/get-started">Get Started</a></li>
          
        </ul>
      </div>
    
      <div class="width-1-12 project-links">
        <span>Contribute</span>
        <ul class="footer-links width-1-12">
          
            <li><a href="https://twitter.com/quarkusio">Follow us</a></li>
          
            <li><a href="https://github.com/quarkusio">GitHub</a></li>
          
            <li><a href="/security">Security&nbsp;policy</a></li>
          
        </ul>
      </div>
    
      <div class="width-1-12 project-links">
        <span>Get Help</span>
        <ul class="footer-links width-1-12">
          
            <li><a href="https://groups.google.com/forum/#!forum/quarkus-dev">Forums</a></li>
          
            <li><a href="https://quarkusio.zulipchat.com">Chatroom</a></li>
          
        </ul>
      </div>
    

    
      <div class="width-3-12 more-links">
        <span>Quarkus is made of community projects</span>
        <ul class="footer-links">
          
            <li><a href="https://vertx.io/" target="_blank">Eclipse Vert.x</a></li>
          
            <li><a href="https://microprofile.io" target="_blank">Eclipse MicroProfile</a></li>
          
            <li><a href="https://hibernate.org" target="_blank">Hibernate</a></li>
          
            <li><a href="https://netty.io" target="_blank">Netty</a></li>
          
            <li><a href="https://resteasy.github.io" target="_blank">RESTEasy</a></li>
          
            <li><a href="https://camel.apache.org" target="_blank">Apache Camel</a></li>
          
            <li><a href="https://code.quarkus.io/" target="_blank">And many more...</a></li>
          
        </ul>
      </div>
    
  </div>
</div>
  <div class="content redhat-footer">
  <div class="grid-wrapper">
    <span class="licence">
      <i class="fab fa-creative-commons"></i><i class="fab fa-creative-commons-by"></i> <a href="https://creativecommons.org/licenses/by/3.0/" target="_blank">CC by 3.0</a> | <a href="https://www.redhat.com/en/about/privacy-policy">Privacy Policy</a>
    </span>
    <span class="redhat">
      Sponsored by
    </span>
    <span class="redhat-logo">
      <a href="https://www.redhat.com/" target="_blank"><img src="/assets/images/redhat_reversed.svg"></a>
    </span>
  </div>
</div>


  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js" integrity="sha384-8gBf6Y4YYq7Jx97PIqmTwLPin4hxIzQw5aDmUg/DDhul9fFpbbLcLh3nTIIDJKhx" crossorigin="anonymous"></script>
  <script type="text/javascript" src="/assets/javascript/mobile-nav.js"></script>
  <script type="text/javascript" src="/assets/javascript/scroll-down.js"></script>
  <script src="/assets/javascript/satellite.js" type="text/javascript"></script>
  <script src="https://quarkus.io/guides/javascript/config.js" type="text/javascript"></script>
  <script src="/assets/javascript/search-filter.js" type="text/javascript"></script>
  <script src="/assets/javascript/back-to-top.js" type="text/javascript"></script>
</body>

</html>
